home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Programming / ace_gpl_release / src_ansi / ace / c / menu.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-05  |  2.7 KB  |  135 lines

  1. /* << ACE >>
  2.  
  3.    -- Amiga BASIC Compiler --
  4.  
  5.    ** Parser: menu functions **
  6.    ** Copyright (C) 1998 David Benn
  7.    ** 
  8.    ** This program is free software; you can redistribute it and/or
  9.    ** modify it under the terms of the GNU General Public License
  10.    ** as published by the Free Software Foundation; either version 2
  11.    ** of the License, or (at your option) any later version.
  12.    **
  13.    ** This program is distributed in the hope that it will be useful,
  14.    ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.    ** GNU General Public License for more details.
  17.    **
  18.    ** You should have received a copy of the GNU General Public License
  19.    ** along with this program; if not, write to the Free Software
  20.    ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  21.  
  22.    Author: David J Benn
  23.    Date: 9th,10th November 1993,
  24.    13th January 1994
  25.  */
  26.  
  27. #include "acedef.h"
  28.  
  29. /* externals */
  30. extern int sym;
  31. extern int lastsym;
  32.  
  33. /* functions */
  34. void clear_menu (void)
  35. {
  36. /* MENU CLEAR */
  37.  
  38.   insymbol ();
  39.  
  40.   gen ("jsr", "_ClearMenu", "  ");
  41.   enter_XREF ("_ClearMenu");
  42.   enter_XREF ("_IntuitionBase");
  43. }
  44.  
  45. void wait_menu (void)
  46. {
  47. /* MENU WAIT */
  48.  
  49.   insymbol ();
  50.  
  51.   gen ("jsr", "_WaitMenu", "  ");
  52.   enter_XREF ("_WaitMenu");
  53. }
  54.  
  55. void menu (void)
  56. {
  57. /* MENU menu-id,item-id,state[,title-string[,command-key]]
  58.    MENU WAIT menu-id
  59.    MENU CLEAR
  60.    MENU ON | OFF | STOP
  61.  */
  62.   int mtype;
  63.  
  64.   insymbol ();
  65.  
  66.   if (sym == onsym || sym == offsym || sym == stopsym)
  67.     change_event_trapping_status (lastsym);
  68.   else if (sym == clearsym)
  69.     clear_menu ();
  70.   else if (sym == waitsym)
  71.     wait_menu ();
  72.   else
  73.     {
  74.       if (make_integer (expr ()) == shorttype)
  75.     make_long ();        /* menu-id */
  76.  
  77.       if (sym != comma)
  78.     _error (16);
  79.       else
  80.     {
  81.       insymbol ();
  82.       if (make_integer (expr ()) == shorttype)
  83.         make_long ();    /* item-id */
  84.  
  85.       if (sym != comma)
  86.         _error (16);
  87.       else
  88.         {
  89.           insymbol ();
  90.           if (make_integer (expr ()) == shorttype)
  91.         make_long ();    /* state */
  92.  
  93.           if (sym != comma)
  94.         {
  95.           gen ("jsr", "_ChangeMenuState", "  ");
  96.           gen ("add.l", "#12", "sp");
  97.  
  98.           enter_XREF ("_ChangeMenuState");
  99.           return;
  100.         }
  101.         }
  102.     }
  103.  
  104.       if (sym != comma)
  105.     _error (16);
  106.       else
  107.     {
  108.       insymbol ();
  109.       mtype = expr ();
  110.  
  111.       if (mtype != stringtype)
  112.         _error (4);        /* title-string */
  113.     }
  114.  
  115.       if (sym == comma)
  116.     {
  117.       insymbol ();
  118.       mtype = expr ();
  119.  
  120.       if (mtype != stringtype)
  121.         _error (4);
  122.     }
  123.       else
  124.     gen ("move.l", "#0", "-(sp)");    /* command-key */
  125.  
  126.       /* call function */
  127.       gen ("jsr", "_ModifyMenu", "  ");
  128.       gen ("add.l", "#20", "sp");
  129.  
  130.       enter_XREF ("_ModifyMenu");
  131.       enter_XREF ("_IntuitionBase");
  132.       enter_XREF ("_GfxBase");
  133.     }
  134. }
  135.